import Product from "../Product";
import { connect } from 'react-redux'
import { getAllProducts, asyncAddToCart } from '../store/action/index'

const mapStateToProps = state=>{
  return {
    products: state.product.all,
  }
};

/*函数
const mapDispatchToProps = dispatch => {
  return {
    getProducts(){
      dispatch(getAllProducts())

      // dispatch({
      //   type: 'RES_PRODUCTS',
      //   products: ['苹果','相机','橘子']
      // })
    }
  }
};*/


const mapDispatchToProps = {
  getAllProducts,
  asyncAddToCart
}


const ContainerProduct = connect(
  mapStateToProps,
  mapDispatchToProps
)(Product);

export default ContainerProduct